//
//  HEInputViewPluginConsulReport.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/18.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEInputViewPluginConsulReport.h"
#import "HEConsulRecoderListViewController.h"

@interface HEInputViewPluginConsulReport ()

@property (nonatomic, copy) LCCKIdResultBlock sendCustomMessageHandler;

@end

@implementation HEInputViewPluginConsulReport
@synthesize inputViewRef = _inputViewRef;
@synthesize sendCustomMessageHandler = _sendCustomMessageHandler;

#pragma mark -
#pragma mark - LCCKInputViewPluginSubclassing Method

+ (LCCKInputViewPluginType)classPluginType {
    return LCCKInputViewPluginTypeConsulReport;
}

#pragma mark -
#pragma mark - LCCKInputViewPluginDelegate Method

/*!
 * 插件图标
 */
- (UIImage *)pluginIconImage {
    return IMAGE_NAMED(@"add_report2");
//    return [self imageInBundlePathForImageName:@"add_report"];
}

/*!
 * 插件名称
 */
- (NSString *)pluginTitle {
    return @"咨询报告";
}

/*!
 * 插件对应的 view，会被加载到 inputView 上
 */
- (UIView *)pluginContentView {
    return nil;
}

- (void)pluginDidClicked {
    [super pluginDidClicked];

    [self selectConsulReportHandler];
}

- (void)selectConsulReportHandler {
 
    HEConsulRecoderListViewController *vc = [HEConsulRecoderListViewController new];
    vc.intoType = HEConsulReportVCIntoTypeFromIM;
    [self.conversationViewController.navigationController pushViewController:vc animated:YES];
    
    KWeakSelf
    vc.backBlock = ^(HECosulReportModel * _Nonnull model) {
        if ([weakSelf.inputViewRef.delegate respondsToSelector:@selector(sendMessage:)]) {
            HEIMMessage *message = [[HEIMMessage alloc] init];
            message.modelType = weakSelf.inputViewRef.type;
            message.type = HEIMMessageTypeConsulReport;
            message.title = model.report_name;
            message.text = model.inst_id;
            message.from = weakSelf.inputViewRef.userInfo.id;
            message.to =  weakSelf.inputViewRef.session.sessionId;
            message.actor = HEActorTypeUser;
            HEIMMessageModel *model = [[HEIMMessageModel alloc] initWithMessage: message];
            model.deliveryState = HEIMMessageDeliveryStateDelivering;
            [weakSelf.inputViewRef.delegate sendMessage: model];
        }
    };
}

#pragma mark -
#pragma mark - Private Methods

@end
